package cn.hwh.springframework.beans.factory.support;

import cn.hwh.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wenhao hu
 * @title: DefaultSingletonBeanRegistry
 * @projectName mini-spring
 * @description: TODO
 * @date 2022/1/2411:35
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private final Map<String, Object> singletonObjects = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    protected void addSingleton(String beanName, Object singletonObject) {
        System.out.println("addSingleton:"+beanName+" and "+ singletonObject);
        singletonObjects.put(beanName, singletonObject);
    }
}
